package org.gap.service;

import java.util.List;
import java.util.Set;

import org.gap.domain.Adresses;
import org.gap.domain.CodesPostaux;
import org.gap.domain.Utilisateurs;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/GAP_v2-security-context.xml",
		"file:./resources/GAP_v2-service-context.xml",
		"file:./resources/GAP_v2-dao-context.xml",
		"file:./resources/GAP_v2-web-context.xml" })
@Transactional
public class AdressesServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected AdressesService service;

	/**
	 * Instantiates a new AdressesServiceTest.
	 *
	 */
	public AdressesServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Utilisateurs entity
	 * 
	 */
	@Test
	public void deleteAdressesUtilisateursByAddUserCreation() {
		// TODO: JUnit - Populate test inputs for operation: deleteAdressesUtilisateursByAddUserCreation 
		Integer adresses_addAdresse = 0;
		String related_utilisateursbyaddusercreation_usrUser = null;
		Adresses response = null;
		response = service.deleteAdressesUtilisateursByAddUserCreation(adresses_addAdresse, related_utilisateursbyaddusercreation_usrUser);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteAdressesUtilisateursByAddUserCreation
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findAdressesByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findAdressesByPrimaryKey 
		Integer addAdresse = 0;
		Adresses response = null;
		response = service.findAdressesByPrimaryKey(addAdresse);
		// TODO: JUnit - Add assertions to test outputs of operation: findAdressesByPrimaryKey
	}

	/**
	 * Operation Unit Test
	 * Save an existing Utilisateurs entity
	 * 
	 */
	@Test
	public void saveAdressesUtilisateursByAddUserCreation() {
		// TODO: JUnit - Populate test inputs for operation: saveAdressesUtilisateursByAddUserCreation 
		Integer addAdresse_1 = 0;
		Utilisateurs related_utilisateursbyaddusercreation = new org.gap.domain.Utilisateurs();
		Adresses response = null;
		response = service.saveAdressesUtilisateursByAddUserCreation(addAdresse_1, related_utilisateursbyaddusercreation);
		// TODO: JUnit - Add assertions to test outputs of operation: saveAdressesUtilisateursByAddUserCreation
	}

	/**
	 * Operation Unit Test
	 * Load an existing Adresses entity
	 * 
	 */
	@Test
	public void loadAdressess() {
		Set<Adresses> response = null;
		response = service.loadAdressess();
		// TODO: JUnit - Add assertions to test outputs of operation: loadAdressess
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Utilisateurs entity
	 * 
	 */
	@Test
	public void deleteAdressesUtilisateursByAddUserModification() {
		// TODO: JUnit - Populate test inputs for operation: deleteAdressesUtilisateursByAddUserModification 
		Integer adresses_addAdresse_1 = 0;
		String related_utilisateursbyaddusermodification_usrUser = null;
		Adresses response = null;
		response = service.deleteAdressesUtilisateursByAddUserModification(adresses_addAdresse_1, related_utilisateursbyaddusermodification_usrUser);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteAdressesUtilisateursByAddUserModification
	}

	/**
	 * Operation Unit Test
	 * Return a count of all Adresses entity
	 * 
	 */
	@Test
	public void countAdressess() {
		Integer response = null;
		response = service.countAdressess();
		// TODO: JUnit - Add assertions to test outputs of operation: countAdressess
	}

	/**
	 * Operation Unit Test
	 * Save an existing Adresses entity
	 * 
	 */
	@Test
	public void saveAdresses() {
		// TODO: JUnit - Populate test inputs for operation: saveAdresses 
		Adresses adresses = new org.gap.domain.Adresses();
		service.saveAdresses(adresses);
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Adresses entity
	 * 
	 */
	@Test
	public void deleteAdresses() {
		// TODO: JUnit - Populate test inputs for operation: deleteAdresses 
		Adresses adresses_1 = new org.gap.domain.Adresses();
		service.deleteAdresses(adresses_1);
	}

	/**
	 * Operation Unit Test
	 * Save an existing CodesPostaux entity
	 * 
	 */
	@Test
	public void saveAdressesCodesPostaux() {
		// TODO: JUnit - Populate test inputs for operation: saveAdressesCodesPostaux 
		Integer addAdresse_2 = 0;
		CodesPostaux related_codespostaux = new org.gap.domain.CodesPostaux();
		Adresses response = null;
		response = service.saveAdressesCodesPostaux(addAdresse_2, related_codespostaux);
		// TODO: JUnit - Add assertions to test outputs of operation: saveAdressesCodesPostaux
	}

	/**
	 * Operation Unit Test
	 * Delete an existing CodesPostaux entity
	 * 
	 */
	@Test
	public void deleteAdressesCodesPostaux() {
		// TODO: JUnit - Populate test inputs for operation: deleteAdressesCodesPostaux 
		Integer adresses_addAdresse_2 = 0;
		String related_codespostaux_cdpPays = null;
		String related_codespostaux_cdpCodePostal = null;
		String related_codespostaux_cdpNInsee = null;
		String related_codespostaux_cdpLocalite = null;
		Adresses response = null;
		response = service.deleteAdressesCodesPostaux(adresses_addAdresse_2, related_codespostaux_cdpPays, related_codespostaux_cdpCodePostal, related_codespostaux_cdpNInsee, related_codespostaux_cdpLocalite);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteAdressesCodesPostaux
	}

	/**
	 * Operation Unit Test
	 * Return all Adresses entity
	 * 
	 */
	@Test
	public void findAllAdressess() {
		// TODO: JUnit - Populate test inputs for operation: findAllAdressess 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<Adresses> response = null;
		response = service.findAllAdressess(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllAdressess
	}

	/**
	 * Operation Unit Test
	 * Save an existing Utilisateurs entity
	 * 
	 */
	@Test
	public void saveAdressesUtilisateursByAddUserModification() {
		// TODO: JUnit - Populate test inputs for operation: saveAdressesUtilisateursByAddUserModification 
		Integer addAdresse_3 = 0;
		Utilisateurs related_utilisateursbyaddusermodification = new org.gap.domain.Utilisateurs();
		Adresses response = null;
		response = service.saveAdressesUtilisateursByAddUserModification(addAdresse_3, related_utilisateursbyaddusermodification);
		// TODO: JUnit - Add assertions to test outputs of operation: saveAdressesUtilisateursByAddUserModification
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
